home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Pascal / Snippets / NewFader 2.0 / NewFader.p < prev    next >
Encoding:
Text File  |  1996-05-08  |  4.8 KB  |  175 lines  |  [TEXT/PJMM]

  1. {----------------------------------------------------------------------}
  2. {The Gamma Fading history :}
  3. {}
  4. {On 12/17/92 ,Matt Slot ,fprefec@engin.umich.edu, wrote a C program for performing}
  5. {gamma fading on the Macintosh.}
  6. {}
  7. {Matt last updated that program 6/29/95 to release v1.1.3.}
  8. {}
  9. {On 7/20/93, Matthew Xavier Mora, mxmora@mxmdesigns.com, made a library using the }
  10. {Gamma C code, and wrote a Think Pascal program which sampled the use of that library }
  11. {(including some pascal routines for delaying the fade).}
  12. {}
  13. {In a separate endeavor in 1994, Ingemar Ragnemalm also created a library based upon the }
  14. {C code, added some separate fade in and fade out routines in Pascal, and got a pascal }
  15. {program running the gamma fader in Think Pascal. In July of 95 he updated his project}
  16. {to use Matt's v1.1.3 gamma routines, and added a CW project as well.}
  17. {}
  18. {Happy with having an available gamma fader, us Pascal programmers were still not quite }
  19. {_satisfied_ being that the library was still C-coded.}
  20. {}
  21. {So on 7/13/95, Matthew Mora ported the entire C-code over to Pascal, and got it }
  22. {debugged and running on 7/18/95 in Think Pascal.}
  23. {}
  24. {Ecstatic over the whole thing, on 7/18/95, Bill Catambay created CW projects in }
  25. {68K and PPC demonstrating the Gamma Fading using _pure_ pascal (incorporating }
  26. {Matthew's ported library routines, his older delay routines, tuning for CW, and }
  27. {cleaning the code a bit).}
  28. {}
  29. {07/23/95: Changes by Ingemar R:}
  30. {• Added a Think Pascal lib and added the necessary conditional compilation switches to make it run in both worlds.}
  31. {• Cleaned up the capitalization a bit (to conform with Inside Mac).}
  32. {• Centered the window on the screen.}
  33. {• Modified the picture: now 2k instead of 80k, and easier to edit in the future.}
  34. {I made NO changes in the fading unit except the IFC in the uses clause.}
  35. {}
  36. {05/08/96: Updates by Ingemar R:}
  37. {• CW7 projects. (Not CW8, but at least better than CW5 or 6.)}
  38. {• Changed PBControl and PBStatus to PBControlSync and PBStatusSync.}
  39. {}
  40. {Files in project:}
  41. {}
  42. {NewFader.p  -  This test program for performing a slow fade out, a fast fade in, and}
  43. {                then a fast fade out and a slow fade in.}
  44. {GammaPaslib.p  -  The gamma routines and internal type declarations, all in PASCAL.}
  45. {NewFader.µ.rsrc  -  Resource for About picture.}
  46. {NewFader(68K).µ  -  The 68K CW project for the gamma fading program.}
  47. {NewFader(PPC).µ  -  The PPC CW project for the gamma fading program.}
  48. {NewFader.π - Think Pascal project (added by Ingemar)}
  49. {}
  50. {Works like a charm!}
  51. {}
  52. {Bill Catambay, catambay@aol.com}
  53. {----------------------------------------------------------------------}
  54. program DoubleFade;
  55.  
  56.     uses
  57. {$IFC UNDEFINED THINK_PASCAL}
  58.         ToolUtils, Fonts, SegLoad, Dialogs, Processes, 
  59. {$ENDC}
  60.         GammaPaslib;
  61.  
  62.     var
  63.         oe: integer;
  64.         delayTime: Longint;
  65.         myRect, bounds: Rect;
  66.         myWindow: WindowPtr;
  67.         myPicture: PicHandle;
  68.  
  69.     procedure DelayFadeToBlack (delayTicks: Longint);
  70.  
  71.         var
  72.             i: integer;
  73.             oe: integer;
  74.             finalTicks: Longint;
  75.  
  76.     begin
  77.         i := 100;
  78.         while i > 0 do
  79.             begin
  80.                 oe := DoGammaFade(i);
  81.                 i := i - 1;
  82.                 Delay(delayTicks, finalTicks);
  83.             end;
  84.     end; {DelayFadeToBlack}
  85.  
  86.     procedure FadeToBlack (speed: integer);
  87.  
  88.         var
  89.             i: integer;
  90.             oe: integer;
  91.  
  92.     begin
  93.         i := 100;
  94.         while (i >= 0) do
  95.             begin
  96.                 oe := DoGammaFade(i);
  97.                 i := i - speed;
  98.             end;
  99.     end; {FadeToBlack}
  100.  
  101.     procedure FadeFromBlack (speed: integer);
  102.  
  103.         var
  104.             i: integer;
  105.             oe: integer;
  106.  
  107.     begin
  108.         i := 0;
  109.         while (i <= 100) do
  110.             begin
  111.                 oe := DoGammaFade(i);
  112.                 i := i + speed;
  113.             end;
  114.     end; {FadeFromBlack}
  115.  
  116.     procedure DelayFadeFromBlack (delayTicks: Longint);
  117.  
  118.         var
  119.             i: integer;
  120.             oe: integer;
  121.             finalTicks: Longint;
  122.  
  123.     begin
  124.         i := 0;
  125.         while (i <= 100) do
  126.             begin
  127.                 oe := DoGammaFade(i);
  128.                 i := i + 1;
  129.                 Delay(delayTicks, finalTicks);
  130.             end;
  131.     end; {DelayFadeFromBlack}
  132.  
  133.     procedure ToolboxInit;
  134.  
  135.     begin
  136. {$IFC UNDEFINED THINK_PASCAL}
  137.         InitGraf(@qd.thePort);
  138.         InitFonts;
  139.         InitWindows;
  140.         InitMenus;
  141.         TEinit;
  142.         InitDialogs(nil);
  143. {$ENDC}
  144.         MaxApplZone;
  145.         InitCursor;
  146.     end; {ToolboxInit}
  147.  
  148. begin {Main program}
  149.     ToolboxInit;
  150.     delayTime := 1;
  151.     if not isGammaAvailable then
  152.         ExitToShell;
  153.     oe := SetupGammaTools;
  154. {Center the picture's bounds on the screen}
  155. {$IFC UNDEFINED THINK_PASCAL}
  156.     bounds := qd.screenBits.bounds;
  157. {$ELSEC}
  158.     bounds := screenBits.bounds;
  159. {$ENDC}
  160.     myPicture := GetPicture(128);
  161.     myRect := myPicture^^.picFrame;
  162.     OffsetRect(myRect, (bounds.right - bounds.left - myRect.right - myRect.left) div 2, (bounds.bottom - bounds.top - myRect.bottom - myRect.top) div 2);
  163. {Fade and then create the window}
  164.     DelayFadeToBlack(delaytime);
  165.     myWindow := NewCWindow(nil, myRect, '', TRUE, plainDBox, Pointer(-1), FALSE, 0);
  166.     SetPort(myWindow);
  167.     DrawPicture(myPicture, myWindow^.portRect);
  168.     FadeFromBlack(2);
  169.     repeat
  170.     until Button;
  171.     FadeToBlack(2);
  172.     HideWindow(mywindow);
  173.     DelayFadeFromBlack(delaytime);
  174.     oe := DisposeGammaTools;
  175. end.